home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ 6⁄15⁄90 / 1420-Type Casting Problem-Jun90 next >
Encoding:
Text File  |  1990-06-15  |  1.7 KB  |  60 lines  |  [TEXT/GEOL]

  1. Item    2908065                         9-June-90        11:39PDT
  2.  
  3. From:   PEMD                            CH DEV PEMD Group, Zurich,IDV
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.  
  7. Sub:    Type Casting Problem
  8.  
  9. Hi Everyone,
  10.  
  11. In converting a MacApp 1.1.1 application to MacApp 2.0, I've run into a
  12. bewildering problem in type casting.
  13.  
  14. A window type is subclassed as follows:
  15.  
  16.     TDiscWindow = OBJECT(TWindow)
  17.            fGrView:TGrView;
  18.          PROCEDURE TDiscWindow.Activate(entering: BOOLEAN);OVERRIDE;
  19.    End; {TDiscWindow}
  20.  
  21. The window is created from a resource with the following call from
  22. TDiscDocoument.DoCreateViews:
  23.     aDiscWindow:=TDiscWindow(NewTemplateWindow(kDiscWindowType,SELF));
  24.  
  25. The resource code is:
  26.  
  27. resource 'view' (kDiscWindowType, purgeable) { {
  28.    root, 'WIND', { 50, 15 }, { 200, 435 }, sizeVariable, sizeVariable, shown,
  29. enabled,
  30.    Window {
  31.    "",
  32.    zoomDocProc, goAwayBox, resizable, modeless, ignoreFirstClick,
  33. freeOnClosing,
  34.    disposeOnFree, DoesntcloseDocument, openWithDocument, dontAdaptToScreen,
  35. stagger,
  36.    forceOnScreen, dontCenter, NoId, "<<<>>>" };
  37.  
  38.    'WIND', IncludeViews { kDiscViewType};
  39. } };
  40.  
  41. resource 'view' (kDiscViewType, purgeable) { {
  42.    root, 'GRPH', { 0, 0 }, { 200, 435 }, sizeSuperView, sizeSuperView, shown,
  43. enabled,
  44.    view { "TGrView" };
  45. } };
  46.  
  47. All compiles fine.  However, evry time NewTemplateWindow is called, the program
  48. goes into the debugger with "Object type coercion error."
  49.  
  50. Does anyone have any suggestions.  I've tried lots of alternatives with no
  51. success.
  52.  
  53. aWindow:=TDiscWindow(NewTemplateWindow(kDiscWindowType,SELF)); works fine where
  54. aWindow:    TWindow.  Then aDiscWindow:=TDiscWindow(aWindow); fails with the
  55. coercion error message.
  56.  
  57. Thanks,
  58. Ernie Rosenberg
  59.  
  60.